package com.yenlien.traceyun.plant.controller;

import com.yenlien.traceyun.plant.entity.ColdCategory;
import com.yenlien.traceyun.plant.service.ColdCategoryService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Date 2022/8/30
 * @Author jiaLong
 * @Descript
 */
@RestController
@RequestMapping("/coldCategory")
public class ColdCategoryController extends BaseController {

    @Autowired
    private ColdCategoryService coldCategoryService;


    @PostMapping(value = "/save")
    public Object save(@RequestBody ColdCategory coldCategory, HttpServletRequest request)  {
//        MultipartFile file = ((MultipartHttpServletRequest) request).getFile("files");
        return success(coldCategoryService.save(coldCategory));
    }

    // 如果携带id参数则查询指定该ID下(不含自己)的类名 否则查询所有
    @GetMapping(value = "/loadById")
    public Object loadById(String id, String type)  {
        return success(coldCategoryService.loadById(id, type));
    }

    @GetMapping(value = "/delById/{id}")
    public Object delById(@PathVariable("id") String id)  {
        coldCategoryService.delById(id);
        return success("success");
    }



    @GetMapping(value = "/loadAllParent")
    public Object loadAllParent(String type)  {
        return success(coldCategoryService.loadAllParent(type));
    }



}
